import { ref } from "vue"
import PageDialog from "@/components/page-dialog"
import mitter from "@/utils/miit"
export const pageDialogRef = ref<InstanceType<typeof PageDialog>>()

export const handlerDialog = (row: any) => {
  // 接收数据
  console.log("PageDialog接受了事件")
  console.log(row)
  // 如果有数据,表明需要展示到dialog对话框上
  if (row.id) {
    const fn = pageDialogRef.value?.dialogShowRowDate()
    if (fn instanceof Function) {
      // 发出事件
      mitter.emit("rowData", row)
      fn(row)
    }
  } else {
    const fn = pageDialogRef.value?.showEmptyDialog()
    // if(fn instanceof Function) {
    //   fn(row)
    // }
  }
}
